﻿<!--
 * Copyright (c) 2010, Andriy Syrov
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided 
 * that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of conditions and the 
 * following disclaimer.
 * 
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 
 * the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 * Neither the name of Andriy Syrov nor the names of his contributors may be used to endorse or promote 
 * products derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 *   
 -->

<UserControl
    x:Class="TimelineEx.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    TextOptions.TextHintingMode="Animated"
    xmlns:timeline="clr-namespace:TimelineLibrary;assembly=TimelineLibrary"
    xmlns:local="clr-namespace:TimelineExLib;assembly=TimelineExLib"
    d:DesignHeight="300"
    d:DesignWidth="400">
    
    <Grid
        x:Name="LayoutRoot"
        Background="White">

        <Grid
            Background="White"
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch">
            
            <Grid.RowDefinitions>
                <RowDefinition
                    Height="Auto"></RowDefinition>                
                <RowDefinition
                    Height="Auto"></RowDefinition>
                <RowDefinition
                    Height="*"></RowDefinition>
            </Grid.RowDefinitions>

            <TextBlock
                VerticalAlignment="Center"
                Margin="4 0 0 0"
                Grid.Row="0"
                FontSize="9"
                FontStyle="Italic"
                Foreground="DarkGreen"
                TextWrapping="Wrap"
                Text="Here you can move events (by dragging them to other position), change event size or duration by dragging small rectangles 
in top/left and bottom/right event corners. If you hit [Reload Data From XML] events restored in original state. if you then move,
or resize or change duration of events and then hit [Save Events] -> [Clear Events] -> [Restore Saved Events] you will notice 
that the system remembers your changes to timeline events.">
            </TextBlock>

            <StackPanel
                Margin="4"
                Grid.Row="1"
                Orientation="Horizontal">

                <CheckBox
                    VerticalAlignment="Center"
                    Margin="4 0 0 0"
                    Click="EditModeClick"
                    IsChecked="True"
                    Content="Edit Mode"></CheckBox>

                <CheckBox
                    VerticalAlignment="Center"
                    Margin="4 0 0 0"
                    Click="AllowChangeDatesClick"
                    IsChecked="False"
                    Content="Allow Change Dates"></CheckBox>

                <Button
                    VerticalAlignment="Center"
                    Margin="4 0 0 0"
                    Click="OnReloadClick"
                    Content="Reload Data From XML"></Button>

                <Button
                    VerticalAlignment="Center"
                    Click="OnSaveClick"
                    Margin="4 0 0 0"
                    Content="Save Events"></Button>

                <Button
                    VerticalAlignment="Center"
                    Margin="4 0 0 0"
                    Click="OnClearClick"
                    Content="Clear Events"></Button>

                <Button
                    VerticalAlignment="Center"
                    Margin="4 0 0 0"
                    Click="OnLoadSavedEventsClick"
                    Content="Restore Saved Events"></Button>

                <Button
                    VerticalAlignment="Center"
                    Margin="20 0 0 0"
                    Click="OnAddNewEventClick"
                    Content="Add New Event"></Button>

            </StackPanel>
            
            
            <local:TimelineTrayEx
                x:Name="timeline"
                Grid.Row="2"
                EditMode="True"
                CalendarType="gregorian"
                HorizontalAlignment="Stretch"
                MinDateTime="01/01/1830"
                RecalculateEventTopPosition="False"
                MaxDateTime="01/01/1930"
                CurrentDateTime="11/01/1855">

                <Grid.RowDefinitions>
                    <RowDefinition
                        Height="Auto" />
                    <RowDefinition
                        Height="*" />
                    <RowDefinition
                        Height="50" />
                </Grid.RowDefinitions>
                
                <timeline:TimelineTray.Urls>
                    <timeline:UriInfo
                        Url="http://localhost:4545/Monet.xml" />
                </timeline:TimelineTray.Urls>

                <timeline:TimelineToolbox
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Grid.Row="0"></timeline:TimelineToolbox>

                <local:TimelineBandEx
                    Grid.Row="1"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    IsMainBand="True"
                    ItemSourceType="years"
                    HorizontalAlignment="Stretch"
                    TimelineWindowSize="20"
                    MaxEventHeight="250" />

                <local:TimelineBandEx
                    Grid.Row="2"
                    Grid.ColumnSpan="2"
                    Grid.Column="0"
                    HorizontalAlignment="Stretch"
                    ItemSourceType="decades"
                    TimelineWindowSize="16"
                    MaxEventHeight="4" />

            </local:TimelineTrayEx>

        </Grid>
    </Grid>
</UserControl>
